package com.fr.chart.plot;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.core.glyph.PiePlotGlyph;
import com.fr.chart.core.glyph.PlotGlyph;
import com.fr.data.ChartData;
import com.fr.data.impl.ReportChartData;
import java.util.ArrayList;
import java.util.List;

public class PiePlot extends Plot
{
  private static final long serialVersionUID = -4335570991687277300L;
  protected int startAngle = 100;
  protected int separatePercent = 0;

  public PlotGlyph createPlotGlyph(ChartData paramChartData)
  {
    PiePlotGlyph localPiePlotGlyph = new PiePlotGlyph();
    paramChartData = create65Data4New(paramChartData);
    install4PlotGlyph(localPiePlotGlyph, paramChartData);
    return localPiePlotGlyph;
  }

  protected ChartData create65Data4New(ChartData paramChartData)
  {
    int i = paramChartData.getSeriesCount();
    int j = paramChartData.getCategoryLabelCount();
    if (i == 1)
    {
      Object[] arrayOfObject1 = new Object[j];
      for (int k = 0; k < j; ++k)
        arrayOfObject1[k] = paramChartData.getCategoryLabel(k);
      Object[] arrayOfObject2 = new Object[i];
      for (int l = (i == 1) ? 0 : 1; l < i; ++l)
        arrayOfObject2[l] = paramChartData.getSeriesLabel(l);
      ArrayList localArrayList1 = new ArrayList();
      ArrayList localArrayList2 = new ArrayList();
      for (int i1 = 0; i1 < j; ++i1)
      {
        localArrayList2 = new ArrayList();
        localArrayList2.add(paramChartData.getValueAt(0, i1));
        localArrayList1.add(localArrayList2.toArray());
      }
      Object[][] arrayOfObject = (Object[][])localArrayList1.toArray(new Object[1][]);
      paramChartData = new ReportChartData(arrayOfObject2, arrayOfObject1, arrayOfObject);
    }
    return paramChartData;
  }

  public void install4PlotGlyph(PiePlotGlyph paramPiePlotGlyph, ChartData paramChartData)
  {
    super.install4PlotGlyph(paramPiePlotGlyph, paramChartData);
    paramPiePlotGlyph.setSeparatePercent(this.separatePercent);
    paramPiePlotGlyph.setStartAngle(this.startAngle);
  }

  public void setStartAngle(int paramInt)
  {
    this.startAngle = paramInt;
  }

  public int getStartAngle()
  {
    return this.startAngle;
  }

  public void setSeparatePercent(int paramInt)
  {
    this.separatePercent = paramInt;
  }

  public int getSeparatePercent()
  {
    return this.separatePercent;
  }

  public boolean match4GUI(Plot paramPlot)
  {
    return ((super.match4GUI(paramPlot)) && (((PiePlot)paramPlot).getSeparatePercent() == getSeparatePercent()));
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Plot");
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("PieAttr").attr("startAngle", this.startAngle).attr("separate", this.separatePercent).end();
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if ("PieAttr".equals(str1))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("startAngle")) != null)
          setStartAngle(Integer.parseInt(str2));
        if ((str2 = paramXMLableReader.getAttr("separate")) != null)
          setSeparatePercent(Integer.parseInt(str2));
      }
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof PiePlot))
      return false;
    PiePlot localPiePlot = (PiePlot)paramObject;
    if (!(super.equals(localPiePlot)))
      return false;
    if (localPiePlot.getStartAngle() != getStartAngle())
      return false;
    return (localPiePlot.getSeparatePercent() == getSeparatePercent());
  }
}